package com.kmvc.message.activity;

import com.kmvc.message.R;
import com.kmvc.ui.IphoneTitleBarActivity;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class SetTextSizeActivity extends IphoneTitleBarActivity implements
		OnCheckedChangeListener {

	private RadioGroup radioGroup;
	private SharedPreferences sp;
	private Editor editor;
	private String checkedString;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.set_text_size);

		setTitle(R.string.textsize);
		setLeftButton(R.string.goback, null);

		sp = getSharedPreferences("com.kmvc.message_preferences", 0);
		editor = sp.edit();

		radioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
		radioGroup.setOnCheckedChangeListener(this);

		checkedString = sp.getString("sizelist", "");

		for (int i = 0; i < 5; i++) {
			if (checkedString.equals((i+""))) {
				radioGroup.check(i + R.id.radio6);
			}
		}
	}

	@Override
	public void onCheckedChanged(RadioGroup arg0, int i) {
		editor.putString("sizelist", "" + (i - R.id.radio6));
		editor.commit();
	}
}
